package com.muye.dianli.activity;

import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.muye.dianli.BaseActivity;
import com.muye.dianli.R;

public class SettingActivity extends BaseActivity implements OnClickListener
{
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		getWindow().setFormat(PixelFormat.RGBA_8888);
		setContentView(R.layout.setting_layout);
		createTitle();
		initWidget();
	}
	
	@Override
	protected void onDestroy()
	{
		super.onDestroy();
	}
	
	/**
	 * 初始化标题栏
	 */
	private void createTitle()
	{
		TextView titleName = (TextView) findViewById(R.id.title_bar_name_text_view);
		titleName.setText("设置");
		titleName.setTextColor(getResources().getColor(R.color.white));
		ImageView leftBtn = (ImageView) findViewById(R.id.title_bar_left_image_view);
		leftBtn.setImageResource(R.drawable.title_back_icon);
		leftBtn.setVisibility(View.VISIBLE);
		leftBtn.setOnClickListener(this);
	}
	
	/**
	 * 初始化控件
	 */
	private void initWidget()
	{
		RelativeLayout introduceBtn = (RelativeLayout) findViewById(R.id.setting_layout_introduce_layout_btn);
		introduceBtn.setOnClickListener(this);
		RelativeLayout feedbackBtn = (RelativeLayout) findViewById(R.id.setting_layout_feedback_layout_btn);
		feedbackBtn.setOnClickListener(this);
		RelativeLayout contactBtn = (RelativeLayout) findViewById(R.id.setting_layout_contact_layout_btn);
		contactBtn.setOnClickListener(this);
		RelativeLayout checkBtn = (RelativeLayout) findViewById(R.id.setting_layout_check_layout_btn);
		checkBtn.setOnClickListener(this);
	}
	
	@Override
	public void onClick(View v)
	{
		switch (v.getId())
		{
			case R.id.title_bar_left_image_view:
				finish();
				break;
			case R.id.setting_layout_introduce_layout_btn:// 企业简介
				Intent intent0 = new Intent(SettingActivity.this, IntroduceActivity.class);
				startActivity(intent0);
				break;
			case R.id.setting_layout_feedback_layout_btn:// 意见反馈
				Intent intent1 = new Intent(SettingActivity.this, FeedbackActivity.class);
				startActivity(intent1);
				break;
			case R.id.setting_layout_contact_layout_btn:// 联系我们
				Intent intent2 = new Intent(SettingActivity.this, ContactUsActivity.class);
				startActivity(intent2);
				break;
			case R.id.setting_layout_check_layout_btn:// 检查更新
				Intent intent3 = new Intent(SettingActivity.this, CheckActivity.class);
				startActivity(intent3);
				break;
			default:
				break;
		}
	}
}
